//
//  MNDAlertViewController.m
//  minidai
//
//  Created by 容贤郁 on 2018/5/8.
//  Copyright © 2018年 迷你金服. All rights reserved.
//

#import "MNDAlertViewController.h"

@interface MNDAlertViewController ()

@property (weak, nonatomic) IBOutlet UIView *springView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *messageLabel;
@property (weak, nonatomic) IBOutlet UIButton *confirmButton;

@end

@implementation MNDAlertViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.springView.transform = CGAffineTransformMakeScale(0.2, 0.2);
    
    [self.confirmButton addTarget:self action:@selector(closeAlertAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [UIView animateWithDuration: 0.7
                          delay: 0.0
         usingSpringWithDamping: 0.5
          initialSpringVelocity: 0.1
                        options: UIViewAnimationOptionCurveEaseIn
                     animations: ^{
                         
                         self.springView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);
                     }
                     completion:^(BOOL finished) {
                         
                     }];
}

- (void)closeAlertAction:(UIButton *)sender {
    [self.view removeFromSuperview];
    
    [self removeFromParentViewController];
}

- (void)setAlertTitle:(NSString *)alertTitle {
    _alertTitle = alertTitle;
    
    self.titleLabel.text = alertTitle;
}

- (void)setAlertMessage:(NSString *)alertMessage {
    _alertMessage = alertMessage;
    
    self.messageLabel.text = alertMessage;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
